1 /* 2 3 Boost Software License - Version 1.0 - August 17th, 2003 4 5 Permission is hereby granted, free of charge, to any person or organization 6 obtaining a copy of the software and accompanying documentation covered by 7 this license (the "Software") to use, reproduce, display, distribute, 8 execute, and transmit the Software, and to prepare derivative works of the 9 Software, and to permit third-parties to whom the Software is furnished to 10 do so, all subject to the following: 11 12 The copyright notices in the Software and this entire statement, including 13 the above license grant, this restriction and the following disclaimer, 14 must be included in all copies of the Software, in whole or in part, and 15 all derivative works of the Software, unless such copies or derivative 16 works are solely in the form of machine-executable object code generated by 17 a source language processor. 18 19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT 22 SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE 23 FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, 24 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 25 DEALINGS IN THE SOFTWARE. 26 27 */ 28 29 module derelict.glib.gthread; 30 31 import derelict.glib.gtypes; 32 import derelict.glib.glibconfig; 33 import derelict.glib.gquark; 34 import derelict.glib.gerror; 35 import core.stdc.config; 36 37 extern (C): 38 39 alias _Anonymous_0 GThreadError; 40 alias void* function (void*) GThreadFunc; 41 alias _GThread GThread; 42 alias _GMutex GMutex; 43 alias _GRecMutex GRecMutex; 44 alias _GRWLock GRWLock; 45 alias _GCond GCond; 46 alias _GPrivate GPrivate; 47 alias _GOnce GOnce; 48 alias _Anonymous_1 GOnceStatus; 49 50 enum _Anonymous_0 51 { 52 G_THREAD_ERROR_AGAIN = 0 53 } 54 55 enum _Anonymous_1 56 { 57 G_ONCE_STATUS_NOTCALLED = 0, 58 G_ONCE_STATUS_PROGRESS = 1, 59 G_ONCE_STATUS_READY = 2 60 } 61 62 struct _GRWLock 63 { 64 gpointer p; 65 guint[2] i; 66 } 67 68 struct _GCond 69 { 70 gpointer p; 71 guint[2] i; 72 } 73 74 struct _GRecMutex 75 { 76 gpointer p; 77 guint[2] i; 78 } 79 80 struct _GPrivate 81 { 82 gpointer p; 83 GDestroyNotify notify; 84 gpointer[2] future; 85 } 86 87 struct _GOnce 88 { 89 GOnceStatus status; 90 gpointer retval; 91 } 92 93 struct _GThread; 94 95 96 union _GMutex 97 { 98 gpointer p; 99 guint[2] i; 100 } 101 102 103 104 version(Derelict_Link_Static) 105 { 106 extern( C ) nothrow 107 { 108 GQuark g_thread_error_quark(); 109 GThread* g_thread_ref(GThread* thread); 110 void g_thread_unref(GThread* thread); 111 GThread* g_thread_new(const(gchar)* name, GThreadFunc func, gpointer data); 112 GThread* g_thread_try_new(const(gchar)* name, GThreadFunc func, gpointer data, GError** error); 113 GThread* g_thread_self(); 114 void g_thread_exit(gpointer retval); 115 gpointer g_thread_join(GThread* thread); 116 void g_thread_yield(); 117 void g_mutex_init(GMutex* mutex); 118 void g_mutex_clear(GMutex* mutex); 119 void g_mutex_lock(GMutex* mutex); 120 gboolean g_mutex_trylock(GMutex* mutex); 121 void g_mutex_unlock(GMutex* mutex); 122 void g_rw_lock_init(GRWLock* rw_lock); 123 void g_rw_lock_clear(GRWLock* rw_lock); 124 void g_rw_lock_writer_lock(GRWLock* rw_lock); 125 gboolean g_rw_lock_writer_trylock(GRWLock* rw_lock); 126 void g_rw_lock_writer_unlock(GRWLock* rw_lock); 127 void g_rw_lock_reader_lock(GRWLock* rw_lock); 128 gboolean g_rw_lock_reader_trylock(GRWLock* rw_lock); 129 void g_rw_lock_reader_unlock(GRWLock* rw_lock); 130 void g_rec_mutex_init(GRecMutex* rec_mutex); 131 void g_rec_mutex_clear(GRecMutex* rec_mutex); 132 void g_rec_mutex_lock(GRecMutex* rec_mutex); 133 gboolean g_rec_mutex_trylock(GRecMutex* rec_mutex); 134 void g_rec_mutex_unlock(GRecMutex* rec_mutex); 135 void g_cond_init(GCond* cond); 136 void g_cond_clear(GCond* cond); 137 void g_cond_wait(GCond* cond, GMutex* mutex); 138 void g_cond_signal(GCond* cond); 139 void g_cond_broadcast(GCond* cond); 140 gboolean g_cond_wait_until(GCond* cond, GMutex* mutex, gint64 end_time); 141 gpointer g_private_get(GPrivate* key); 142 void g_private_set(GPrivate* key, gpointer value); 143 void g_private_replace(GPrivate* key, gpointer value); 144 gpointer g_once_impl(GOnce* once, GThreadFunc func, gpointer arg); 145 gboolean g_once_init_enter(void* location); 146 void g_once_init_leave(void* location, gsize result); 147 } 148 } 149 else 150 { 151 extern( C ) nothrow 152 { 153 alias da_g_thread_error_quark = GQuark function(); 154 alias da_g_thread_ref = GThread* function(GThread* thread); 155 alias da_g_thread_unref = void function(GThread* thread); 156 alias da_g_thread_new = GThread* function(const(gchar)* name, GThreadFunc func, gpointer data); 157 alias da_g_thread_try_new = GThread* function(const(gchar)* name, GThreadFunc func, gpointer data, GError** error); 158 alias da_g_thread_self = GThread* function(); 159 alias da_g_thread_exit = void function(gpointer retval); 160 alias da_g_thread_join = gpointer function(GThread* thread); 161 alias da_g_thread_yield = void function(); 162 alias da_g_mutex_init = void function(GMutex* mutex); 163 alias da_g_mutex_clear = void function(GMutex* mutex); 164 alias da_g_mutex_lock = void function(GMutex* mutex); 165 alias da_g_mutex_trylock = gboolean function(GMutex* mutex); 166 alias da_g_mutex_unlock = void function(GMutex* mutex); 167 alias da_g_rw_lock_init = void function(GRWLock* rw_lock); 168 alias da_g_rw_lock_clear = void function(GRWLock* rw_lock); 169 alias da_g_rw_lock_writer_lock = void function(GRWLock* rw_lock); 170 alias da_g_rw_lock_writer_trylock = gboolean function(GRWLock* rw_lock); 171 alias da_g_rw_lock_writer_unlock = void function(GRWLock* rw_lock); 172 alias da_g_rw_lock_reader_lock = void function(GRWLock* rw_lock); 173 alias da_g_rw_lock_reader_trylock = gboolean function(GRWLock* rw_lock); 174 alias da_g_rw_lock_reader_unlock = void function(GRWLock* rw_lock); 175 alias da_g_rec_mutex_init = void function(GRecMutex* rec_mutex); 176 alias da_g_rec_mutex_clear = void function(GRecMutex* rec_mutex); 177 alias da_g_rec_mutex_lock = void function(GRecMutex* rec_mutex); 178 alias da_g_rec_mutex_trylock = gboolean function(GRecMutex* rec_mutex); 179 alias da_g_rec_mutex_unlock = void function(GRecMutex* rec_mutex); 180 alias da_g_cond_init = void function(GCond* cond); 181 alias da_g_cond_clear = void function(GCond* cond); 182 alias da_g_cond_wait = void function(GCond* cond, GMutex* mutex); 183 alias da_g_cond_signal = void function(GCond* cond); 184 alias da_g_cond_broadcast = void function(GCond* cond); 185 alias da_g_cond_wait_until = gboolean function(GCond* cond, GMutex* mutex, gint64 end_time); 186 alias da_g_private_get = gpointer function(GPrivate* key); 187 alias da_g_private_set = void function(GPrivate* key, gpointer value); 188 alias da_g_private_replace = void function(GPrivate* key, gpointer value); 189 alias da_g_once_impl = gpointer function(GOnce* once, GThreadFunc func, gpointer arg); 190 alias da_g_once_init_enter = gboolean function(void* location); 191 alias da_g_once_init_leave = void function(void* location, gsize result); 192 } 193 194 __gshared 195 { 196 da_g_thread_error_quark g_thread_error_quark; 197 da_g_thread_ref g_thread_ref; 198 da_g_thread_unref g_thread_unref; 199 da_g_thread_new g_thread_new; 200 da_g_thread_try_new g_thread_try_new; 201 da_g_thread_self g_thread_self; 202 da_g_thread_exit g_thread_exit; 203 da_g_thread_join g_thread_join; 204 da_g_thread_yield g_thread_yield; 205 da_g_mutex_init g_mutex_init; 206 da_g_mutex_clear g_mutex_clear; 207 da_g_mutex_lock g_mutex_lock; 208 da_g_mutex_trylock g_mutex_trylock; 209 da_g_mutex_unlock g_mutex_unlock; 210 da_g_rw_lock_init g_rw_lock_init; 211 da_g_rw_lock_clear g_rw_lock_clear; 212 da_g_rw_lock_writer_lock g_rw_lock_writer_lock; 213 da_g_rw_lock_writer_trylock g_rw_lock_writer_trylock; 214 da_g_rw_lock_writer_unlock g_rw_lock_writer_unlock; 215 da_g_rw_lock_reader_lock g_rw_lock_reader_lock; 216 da_g_rw_lock_reader_trylock g_rw_lock_reader_trylock; 217 da_g_rw_lock_reader_unlock g_rw_lock_reader_unlock; 218 da_g_rec_mutex_init g_rec_mutex_init; 219 da_g_rec_mutex_clear g_rec_mutex_clear; 220 da_g_rec_mutex_lock g_rec_mutex_lock; 221 da_g_rec_mutex_trylock g_rec_mutex_trylock; 222 da_g_rec_mutex_unlock g_rec_mutex_unlock; 223 da_g_cond_init g_cond_init; 224 da_g_cond_clear g_cond_clear; 225 da_g_cond_wait g_cond_wait; 226 da_g_cond_signal g_cond_signal; 227 da_g_cond_broadcast g_cond_broadcast; 228 da_g_cond_wait_until g_cond_wait_until; 229 da_g_private_get g_private_get; 230 da_g_private_set g_private_set; 231 da_g_private_replace g_private_replace; 232 da_g_once_impl g_once_impl; 233 da_g_once_init_enter g_once_init_enter; 234 da_g_once_init_leave g_once_init_leave; 235 } 236 }